<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="UTF-8">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/carousel.css">
    <style>
        .tree li {
            list-style-type: none;
            cursor: pointer;
        }

        table tbody tr:nth-child(odd) {
            background: #F4F4F4;
        }

        table tbody td:nth-child(even) {
            color: #C00;
        }

        #logoimg {
            width: 150px;
            position: absolute;
            left: 15px;
            padding: 5px 5px;
        }

        #logodiv {
            position: absolute;
            left: 165px;
        }

        th, td {
            vertical-align: middle;
            text-align: center;
        }
    </style>
</head>

<body>
<div class="navbar-wrapper ">
    <%--动态导入另一个jsp页面，作用：将公共使用的部分提取出来，然后使用动态导入
              动态导入是不会导入include页面的编译指令的，而是仅仅将被导入页面的body内容插入本页面。--%>
    <jsp:include page="admin-header.jsp"></jsp:include>
</div>
<div class="container-fluid">
    <div class="row ">
        <%--动态导入另一个jsp页面，作用：将公共使用的部分提取出来，然后使用动态导入
                    动态导入是不会导入include页面的编译指令的，而是仅仅将被导入页面的body内容插入本页面。--%>
        <jsp:include page="admin-left.jsp"></jsp:include>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main ">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="glyphicon glyphicon-th"></i> 数据列表</h3>
                </div>
                <hr>
                <div class=" panel-body">
                    <div class="col-md-12 table-responsive">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>标题</th>
                                <th>姓名</th>
                                <th>联系电话</th>
                                <th>请假时间</th>
                                <th>请假理由</th>
                                <th>申请时间</th>
                                <th>状态</th>
                                <th></th>
                                <th>删除</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach var="tbQingjiaPageInfo" items="${tbQingjiaPageInfos.list}">
                                <tr>
                                    <td>${tbQingjiaPageInfo.qingjiaId}</td>
                                    <td><span data-toggle="tooltip"
                                              title="标题">${tbQingjiaPageInfo.qingjiaTitle}</span>
                                    </td>
                                    <td><span data-toggle="tooltip"
                                              title="联系人">${tbQingjiaPageInfo.leaderName}</span>
                                    </td>
                                    <td><span data-toggle="tooltip"
                                              title="联系电话">${tbQingjiaPageInfo.leaderTel}</span>
                                    </td>
                                    <td><span data-toggle="tooltip" title="请假时间">
                                        <fmt:formatDate value="${tbQingjiaPageInfo.startTime}" pattern="yyyy-MM-dd"/> 到
                                        <fmt:formatDate value="${tbQingjiaPageInfo.endTime}"
                                                        pattern="yyyy-MM-dd"/></span></td>
                                    <td><span data-toggle="tooltip"
                                              title="请假理由">${tbQingjiaPageInfo.qingjiaWhy}</span>
                                    </td>
                                    <td><span data-toggle="tooltip" title="申请时间"><fmt:formatDate
                                        value="${tbQingjiaPageInfo.addTime}" pattern="yyyy-MM-dd"/></span></td>
                                    <td>
                                        <c:if test="${tbQingjiaPageInfo.hasAllow == true}">
                                            <button type="button" class="btn btn-warning btn-xs"
                                                    data-toggle="tooltip"
                                                    title="未通过">未通过
                                            </button>
                                        </c:if>
                                        <c:if test="${tbQingjiaPageInfo.hasAllow==false}">
                                            <button type="button" class="btn btn-success btn-xs"
                                                    data-toggle="tooltip"
                                                    title="已通过">已通过
                                            </button>
                                        </c:if>

                                    </td>
                                    <c:if test="${tbQingjiaPageInfo.hasAllow==true}">
                                        <td>
                                            <button type="button" class="btn btn-info btn-xs" data-toggle="tooltip"
                                                    title="审核"
                                                    onclick="shenheOk(${tbQingjiaPageInfo.qingjiaId},this)">
                                                <i
                                                    class=" glyphicon glyphicon-check"></i>
                                            </button>
                                        </td>
                                    </c:if>
                                    <c:if test="${tbQingjiaPageInfo.hasAllow==false}">
                                        <td>
                                            <button type="button" class="btn btn-danger btn-xs"
                                                    data-toggle="tooltip"
                                                    title="拒绝"
                                                    onclick="shenheNo(${tbQingjiaPageInfo.qingjiaId},this)">
                                                <i
                                                    class=" glyphicon glyphicon-remove"></i>
                                            </button>
                                        </td>
                                    </c:if>
                                    <td>
                                        <button type="button" class="btn btn-danger btn-xs" data-toggle="tooltip"
                                                title="删除" onclick="deleteOk(${tbQingjiaPageInfo.qingjiaId})">删除
                                        </button>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="9" align="center">
                                    当前${tbQingjiaPageInfos.pageNum }页,总${tbQingjiaPageInfos.pages }页,总${tbQingjiaPageInfos.total }条记录
                                </td>
                            </tr>
                            <tr>
                                <td colspan="9" align="center">
                                    <ul class="pagination">
                                        <li><a
                                            href="${pageContext.request.contextPath}/tbQingjia/searchQingjiadan?page=1">首页</a>
                                        </li>
                                        <!-- 判断是否有上一页，以便显示点击按钮 -->
                                        <c:if test="${tbQingjiaPageInfos.hasPreviousPage }">
                                            <li>
                                                <a href="${pageContext.request.contextPath}/tbQingjia/searchQingjiadan?page=${tbQingjiaPageInfos.pageNum-1 }"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true">&laquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 遍历页码 -->
                                        <c:forEach items="${tbQingjiaPageInfos.navigatepageNums }" var="page_Num">
                                            <c:if test="${page_Num == tbQingjiaPageInfos.pageNum }">
                                                <li class="active"><a href="#">${page_Num }</a></li>
                                            </c:if>
                                            <c:if test="${page_Num != tbQingjiaPageInfos.pageNum }">
                                                <li><a
                                                    href="${pageContext.request.contextPath}/tbQingjia/searchQingjiadan?page=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                        </c:forEach>
                                        <!-- 判断是否有下一页 -->
                                        <c:if test="${tbQingjiaPageInfos.hasNextPage }">
                                            <li>
                                                <a href="${pageContext.request.contextPath}/tbQingjia/searchQingjiadan?page=${tbQingjiaPageInfos.pageNum+1 }"
                                                   aria-label="Next">
                                                    <span aria-hidden="true">&raquo;</span>
                                                </a>
                                            </li>
                                        </c:if>

                                        <li><a
                                            href="${pageContext.request.contextPath}/tbQingjia/searchQingjiadan?page=${tbQingjiaPageInfos.pages }">末页</a>
                                        </li>
                                    </ul>

                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/resources/jquery/jquery-2.1.1.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/script/docs.min.js"></script>
<script type="text/javascript">
    $(function () {

        $("[data-toggle='tooltip']").tooltip();

        $(".list-group-item").click(function () {
            if ($(this).find("ul")) {
                $(this).toggleClass("tree-closed");
                if ($(this).hasClass("tree-closed")) {
                    $("ul", this).hide("fast");
                } else {
                    $("ul", this).show("fast");
                }
            }
        });

    });

    /*审核户操作*/
    function shenheOk(qingjiaId, obj) {
        //alert("id====" + qingjiaId)
        if (confirm("请确认操作")) {
            $.ajax({
                url: '/tbQingjia/updateStatus',

                data: {
                    qingjiaId: qingjiaId,
                    hasAllow: 0  //表示审核通过
                },
                type: 'POST',
                dataType: 'json',
                success: function (data) {
                    if (data.flag) {
                        alert(data.msg);
                        //location.replace('/tbUser/searchUser')
                        location.reload()
                    } else {
                        alert(data.msg);
                    }
                }
            });
        } else {
            location.reload()
        }
    };

    /*拒绝通过操作*/
    function shenheNo(qingjiaId, obj) {
        //alert("id====" + qingjiaId)
        if (confirm("请确认操作")) {
            $.ajax({
                url: '/tbQingjia/updateStatus',

                data: {
                    qingjiaId: qingjiaId,
                    hasAllow: 1  //1表示拒绝
                },
                type: 'POST',
                dataType: 'json',
                success: function (data) {
                    if (data.flag) {
                        alert(data.msg);
                        //location.replace('/tbUser/searchUser')
                        location.reload()
                    } else {
                        alert(data.msg);
                    }
                }
            });
        } else {
            location.reload()
        }
    }

    //删除操作

    function deleteOk(qingjiaId) {
        if (confirm("确定删除?")) {
            location.replace("/tbQingjia/deleteOk?qingjiaId=" + qingjiaId)
        }
    }
</script>
</body>
</html>
